<?php
/**
 * Event Calendar sidebar
 *
 * @package Blog
 */

// generate a list of filter tabs
$group_guid = $vars['group_guid'];
$filter_context = $vars['filter'];
if ($filter_context=='') $filter_context='all';
if ($group_guid) {
	$url_segment = "event_calendar/group/{$group_guid}/{$vars['start_date']}/{$vars['mode']}/$filter_context";
} else {
	$url_segment = "event_calendar/list/{$vars['start_date']}/{$vars['mode']}/$filter_context";
}

$body = '';
$event_calendar_type_display = elgg_get_plugin_setting('type_display', 'event_calendar');

if ($event_calendar_type_display == 'yes') {
	$type_list = trim(elgg_get_plugin_setting('type_list', 'event_calendar'));
	$type_list_handles = elgg_get_plugin_setting('type_list_handles', 'event_calendar');
	// make sure that we are using Unix line endings
	$type_list = str_replace("\r\n","\n",$type_list);
	$type_list = str_replace("\r","\n",$type_list);
	if ($type_list) {
		$options = array();
		$options[] = '-';
		$bgcolors=get_event_type_bgcolor_array();
		
		echo '<div class="elgg-module  elgg-module-aside">';
		$title = elgg_echo("event_calendar:type_label");
		echo '<div class ="elgg-head"><h3>' . $title . '</h3></div>';
		//echo '<p><label>'.elgg_echo("event_calendar:type_label").'<br />';

		echo "<ul>";
		$body .= '<ul>';
		foreach(explode("\n",$type_list) as $type_item) {
			$type_item = trim($type_item);
			if ($type_list_handles == 'yes') {
				$options[$type_item] = elgg_echo('event_calendar:type:'.$type_item);
			} else {
				$options[$type_item] = $type_item;
			}			
			echo "<li><a id='$bgcolors[$type_item]' class='event_type' href='#'>$options[$type_item]<a></li>";
			$link = elgg_get_site_url() . $url_segment . '/' . $type_item;
			$body .= "<li><a href=\"$link\" title=\"$options[$type_item]\">$options[$type_item]</a></li>";
		}
		echo "</ul>";
		echo '</label></p>';
		$body .= '</ul>';
		
		echo '</div>';  //<div class="elgg-module  elgg-module-aside">
		//$body .= '<p class="description">'.$prefix['event_type'].elgg_echo('event_calendar:type_description').'</p>';
	}
}
//echo $body;
?>
<!-- input id='test123' class='elgg-button' type='button' value='test'/ -->
<script>
$('a.event_type').toggle(
	function() {
	var id=$(this).attr('id');
	var div = $("[style$='"+id+"']");
	//alert(div.attr('class'));
	div.parent().hide();
	},
	function() {
	var id=$(this).attr('id');
	var div = $("[style$='"+id+"']");
	//alert(div.attr('class'));
	div.parent().show();
	}
);

$('#test123').toggle(function() {
alert('test');
var t = $('.fc-content').attr('class');
var t = $('.fc-content div').attr('class');
var t = $('.fc-content div table').attr('class');
var t = $('.fc-content div table+div').attr('style');
var t = $('.fc-content div table+div a:eq(0)').attr('style');
var t = $("[style$='6633CC']").attr('class');
//.find('div:eq(0)').
//find('div:eq(0)').find('a:eq(0)').val();
alert(t);
//$('a').hide();
},function() {
alert('test');
var t = $('.fc-content').attr('class');
//var t = $('.fc-content div div').attr('class');
//.find('div:eq(0)').
//find('div:eq(0)').find('a:eq(0)').val();
alert(t);
//$('a').show();
});
</script>
